﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ContractsList.aspx.cs" Inherits="Operator_ContractsList" MasterPageFile="~/Site.master" %>

<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <br />
    <asp:HyperLink ID="OperatorLink" runat="server" NavigateUrl="~/Operator/OperatorPanel.aspx">Панель оператора</asp:HyperLink> &nbsp;→ 
    <asp:Label ID="ContractLabel" runat="server" Text="Контракты" ForeColor="black" Font-Bold="true"></asp:Label><br/>
<br />

    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
        DataSourceID="SqlDataSourceContracts" DataKeyNames="ContractId" 
        onselectedindexchanged="GridView1_SelectedIndexChanged" 
        ondatabinding="GridView1_DataBinding" AllowSorting="True">
        <Columns>
            <asp:CommandField ShowSelectButton="True" SelectText="Просмотреть" />
            <asp:BoundField DataField="CompanyName" HeaderText="Название предпрития" 
                SortExpression="CompanyName" />
            <asp:BoundField DataField="Expr1" HeaderText="Название кредита" SortExpression="Expr1" />
            <asp:BoundField DataField="CreationDate" HeaderText="Дата получения" 
                SortExpression="CreationDate" />
            <asp:BoundField DataField="Amount" HeaderText="Сумма" 
                SortExpression="Amount" />
            <asp:BoundField DataField="Name" HeaderText="Валюта" 
                SortExpression="Name" />
            <asp:BoundField DataField="ContractId" HeaderText="ContractId" 
                InsertVisible="False" ReadOnly="True" SortExpression="ContractId" 
                Visible="False" />
            <asp:BoundField DataField="CreditID" HeaderText="CreditID" 
                InsertVisible="False" ReadOnly="True" SortExpression="CreditID" 
                Visible="False" />
        </Columns>
        <EmptyDataTemplate>
            Контрактов нет.
        </EmptyDataTemplate>
    </asp:GridView>


    <asp:SqlDataSource ID="SqlDataSourceContracts" runat="server" 
        ConnectionString="<%$ ConnectionStrings:BankDBConnectionString %>" 
        
        
        SelectCommand="SELECT Contract.ContractId, Company.CompanyName, Contract.CreationDate, Contract.Amount, Currency.Name, Credit.Name AS Expr1, Credit.CreditID FROM Contract INNER JOIN Company ON Contract.CompanyId = Company.CompanyId INNER JOIN Credit ON Contract.CreditId = Credit.CreditID INNER JOIN Currency ON Contract.CurrencyId = Currency.CurrencyID INNER JOIN UserProfile ON Company.CompanyId = UserProfile.CompanyId WHERE (Contract.StatusId = 1) AND (UserProfile.OperatotId = @OperatorId)">
        <SelectParameters>
            <asp:Parameter Name="OperatorId" />
        </SelectParameters>
    </asp:SqlDataSource>


</asp:Content>